Skip to content

fix: add Spotless skip flags to Maven and Gradle validation#1946

Open
mashraf-222 wants to merge 2 commits intomainfrom
cf-1080-spotless-skip
Open

fix: add Spotless skip flags to Maven and Gradle validation#1946
mashraf-222 wants to merge 2 commits intomainfrom
cf-1080-spotless-skip

Conversation

@mashraf-222
Copy link
Copy Markdown
Contributor

Problem

Instrumented test files (*__perfinstrumented.java) fail Spotless Maven/Gradle format checks. The validation skip flag lists did not include Spotless, causing build failures on projects like Apache Flink (Spotless 2.43.0), Kafka, and Beam.

Root Cause

_MAVEN_VALIDATION_SKIP_FLAGS in maven_strategy.py and _GRADLE_SKIP_VALIDATION_INIT_SCRIPT in gradle_strategy.py were missing Spotless entries. They already skipped rat, checkstyle, spotbugs, pmd, enforcer, japicmp, and errorprone — but not Spotless.

Fix

Maven: Added -Dspotless.check.skip=true and -Dspotless.apply.skip=true to _MAVEN_VALIDATION_SKIP_FLAGS.

Gradle: Added spotlessCheck, spotlessApply, spotlessJava, spotlessKotlin, spotlessScala to the task disable list in the init script.

Validation

Verified flag works on Apache Flink:

$ mvn spotless:check -pl flink-core -Dspotless.check.skip=true
[INFO] BUILD SUCCESS

Test Coverage

  • test_maven_skip_flags_include_spotless — verifies both Spotless flags present
  • test_maven_skip_flags_include_all_known_plugins — verifies all plugin families covered
  • test_gradle_skip_script_includes_spotless — verifies Gradle script disables Spotless tasks

Closes CF-1080

Instrumented test files fail Spotless format checks on projects like
Apache Flink, Kafka, and Beam. Adds -Dspotless.check.skip=true and
-Dspotless.apply.skip=true to Maven, and spotlessCheck/Apply/Java/
Kotlin/Scala task disabling to the Gradle init script.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 1, 2026

Claude finished @mashraf-222's task in 2m 28s —— View job


PR Review Summary

Checklist

  • Triage PR size (SMALL: ~6 lines of production code changed)
  • Run lint/type checks
  • Resolve stale threads (none found)
  • Code review
  • Duplicate detection
  • No open codeflash-ai[bot] PRs to merge

Prek Checks

All clean — ruff check, ruff format passed with no issues.


Code Review

Maven (maven_strategy.py): The two new flags (-Dspotless.check.skip=true, -Dspotless.apply.skip=true) are correctly added to _MAVEN_VALIDATION_SKIP_FLAGS at the right position (lines 46–47).

Gradle (gradle_strategy.py): The five new task names are correctly appended to the disabled-task list. Disabling the umbrella tasks (spotlessCheck, spotlessApply) is sufficient to block Spotless execution; the per-language additions (spotlessJava, spotlessKotlin, spotlessScala) are a reasonable defensive layer.

Potential gap — POM injection path is incomplete

maven_strategy.py has two independent skip mechanisms:

  1. _MAVEN_VALIDATION_SKIP_FLAGS — CLI -D flags (updated by this PR ✅)
  2. _VALIDATION_SKIP_PROPERTIES_TRUE / inject_validation_skip_properties() — injects <property>true</property> into pom.xml directly (lines 163–171, not updated)

_VALIDATION_SKIP_PROPERTIES_TRUE currently skips checkstyle.skip, spotbugs.skip, pmd.skip, rat.skip, enforcer.skip, japicmp.skip — but not spotless.check.skip or spotless.apply.skip. Both mechanisms run on validation (line 687 injects POM, lines 711/745/769/900 use CLI flags). If Spotless is invoked through the POM injection path (e.g., on a project where the CLI flags are filtered), Spotless won't be skipped.

Fix this →

Additionally, _VALIDATION_PLUGIN_OVERRIDES (the XML-based override injected into the POM build section) doesn't include a Spotless plugin override — though this is a lower-priority issue since _VALIDATION_SKIP_PROPERTIES_TRUE + CLI flags cover the common cases.

Tests: The three new tests are correct and cover the additions well. One note: test_maven_skip_flags_include_all_known_plugins uses a string-join join + in check, which means a flag like -Dspotless_other.skip=true would pass the "spotless" check accidentally — but this is low risk for these well-known plugin names.


Duplicate Detection

No duplicates detected. The Gradle and Maven skip lists are intentionally parallel (not shared), since they use completely different build tool conventions.


Last updated: 2026-04-06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant